package visitor_pattern.impl;

import visitor_pattern.Customer;
import visitor_pattern.CustomerGroup;
import visitor_pattern.Item;
import visitor_pattern.Order;

/**
 * @author 申书航
 * @version 1.0
 * 客户端类，用于演示客户、订单及其报告的创建和访问。
 */
public class Client {

    public static void main(String[] args) {
        //构建客户1
        Customer one = new Customer("张三");
        one.addOrder(new Order("001")
                .addItem(Item.builder().name("大龙虾").number(2).price(20).build())
                .addItem(Item.builder().name("大闸蟹").number(2).price(40).build())
                .addItem(Item.builder().name("皮皮虾").number(2).price(15).build())
        );

        one.addOrder(new Order("002")
                .addItem(Item.builder().name("粉蒸肉").number(2).price(10).build())
                .addItem(Item.builder().name("大肥肠").number(2).price(20).build())
                .addItem(Item.builder().name("红烧肉").number(2).price(20).build())
        );
        //构建客户2
        Customer two = new Customer("李四");
        two.addOrder(new Order("001")
                .addItem(Item.builder().name("酱牛肉").number(4).price(50).build())
                .addItem(Item.builder().name("烤猪蹄").number(5).price(30).build())
                .addItem(Item.builder().name("烧刀子").number(3).price(20).build())
        );
        two.addOrder(new Order("002")
                .addItem(Item.builder().name("五花肉").number(4).price(25).build())
                .addItem(Item.builder().name("里脊肉").number(5).price(20).build())
                .addItem(Item.builder().name("大白菜").number(3).price(2).build())
        );
        //构建客户组
        CustomerGroup customerGroup = new CustomerGroup();
        customerGroup.addCustomer(one);
        customerGroup.addCustomer(two);
        //开始访问
        GeneralReport visitor = new GeneralReport();
        customerGroup.accept(visitor);
        visitor.displayReport();
    }
}
